import api from '../utils/axios'
import qs from 'qs'

import dataUtil from '../utils/dataUtil'

export default {

    /*查询是否收藏*/
    checkIsFaved: function (type, ids) {
        const idsStr = ids.join('&ids=')
        return api.post(`api/v1/favorite/${type}?ids=${idsStr}`).then((res) => {
            return Promise.resolve(res.data)
        })
    },

    /*收藏某类资源*/
    addFav: function (type, id, title) {
        return api.post(`api/v1/favorite/${type}/add?id=${id}&title=${encodeURIComponent(title)}`, ).then((res) => {
            return Promise.resolve(res.data)
        })
    },

    /*删除收藏资源*/
    delFav: function (type, id) {
        return api.post(`api/v1/favorite/${type}/delete?id=${id}`, ).then((res) => {
            return Promise.resolve(res.data)
        })
    },

    /*数据集查询统计*/
    getList: function (body) {
        return api.post(`api/v1/favorite/list`, body).then((res) => {
            return Promise.resolve(dataUtil.formatTableData(res.data))
        })
    },


}
